package com.ruoyi.project.system.controller;

import java.util.List;

import com.ruoyi.project.system.domain.HiddenDangerReport;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.service.IHiddenDangerReportService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 隐患上报Controller
 * 
 * @author ruoyi
 * @date 2021-10-15
 */
@RestController
@RequestMapping("/system/report")
public class HiddenDangerReportController extends BaseController
{
    @Autowired
    private IHiddenDangerReportService hiddenDangerReportService;

    /**
     * 查询隐患上报列表
     */
    @GetMapping("/list")
    public TableDataInfo list(HiddenDangerReport hiddenDangerReport)
    {
        startPage();
        List<HiddenDangerReport> list = hiddenDangerReportService.selectHiddenDangerReportList(hiddenDangerReport);
        return getDataTable(list);
    }

    /**
     * 导出隐患上报列表
     */
    @Log(title = "隐患上报", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HiddenDangerReport hiddenDangerReport)
    {
        List<HiddenDangerReport> list = hiddenDangerReportService.selectHiddenDangerReportList(hiddenDangerReport);
        ExcelUtil<HiddenDangerReport> util = new ExcelUtil<HiddenDangerReport>(HiddenDangerReport.class);
        return util.exportExcel(list, "隐患上报数据");
    }

    /**
     * 获取隐患上报详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(hiddenDangerReportService.selectHiddenDangerReportById(id));
    }

    /**
     * 新增隐患上报
     */
    @Log(title = "隐患上报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HiddenDangerReport hiddenDangerReport)
    {
        return toAjax(hiddenDangerReportService.insertHiddenDangerReport(hiddenDangerReport));
    }

    /**
     * 修改隐患上报
     */
    @Log(title = "隐患上报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HiddenDangerReport hiddenDangerReport)
    {
        return toAjax(hiddenDangerReportService.updateHiddenDangerReport(hiddenDangerReport));
    }

    /**
     * 删除隐患上报
     */
    @Log(title = "隐患上报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hiddenDangerReportService.deleteHiddenDangerReportByIds(ids));
    }
}
